﻿using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;

namespace JWTBasic.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class ValuesController
    {
        [HttpGet]
        public ActionResult<string> Get()
        {
            var claims = new Claim[]
            {
                new Claim(ClaimTypes.Name,"小太洋"),
                new Claim(JwtRegisteredClaimNames.Email,"2609603632@qq.com"),
                new Claim(JwtRegisteredClaimNames.Sub,"111"),//id 或者Uid
                new Claim(JwtRegisteredClaimNames.Alg,"111"),//id 或者Uid
            };

            var jwt = new JwtSecurityToken(claims: claims);

            var jwtToken = new JwtSecurityTokenHandler().WriteToken(jwt);

            return jwtToken;
        }
    }
}
